using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;

namespace RollingKitty
{
    public class DictionaryView<TKey,TValue> : IEnumerable//IDictionary<TKey, TValue>, IDictionary
    {
        IDictionary<TKey, TValue> dictionary;

        public DictionaryView(IDictionary<TKey,TValue> dictionary)
        {
            this.dictionary = dictionary;
        }

        public void Add(TKey key, TValue value)
        {
            throw new NotSupportedException();
        }

        public bool Remove(TKey key)
        {
            throw new NotSupportedException();
        }

        public IEnumerator GetEnumerator()
        {
            return dictionary.GetEnumerator();
        }

        public bool ContainsKey(TKey key)
        {
            return dictionary.ContainsKey(key);
        }

        public bool TryGetValue(TKey key, out TValue value)
        {
            bool result = dictionary.TryGetValue(key, out value);

            return result;
        }

        public TValue this[TKey key]
        {
            get
            {
                return dictionary[key];
            }

            set
            {
                throw new NotSupportedException();
            }
        }

        public ICollection<TKey> Keys
        {
            get
            {
                return new List<TKey>(dictionary.Keys);
            }
        }

        public ICollection<TValue> Values
        {
            get
            {
                return new List<TValue>(dictionary.Values);
            }
        }

        public int Count
        {
            get
            {
                return dictionary.Count;
            }
        }
    }
}
